<template>
  <div class="commodity-page">
    <!-- <c-title :hide="false" text="qweqw"></c-title> -->
    <div class="banner-bg">
      <img :src="storeDetail.store_banner_url" mode="widthFix" />
    </div>

    <div class="commodity-head flex-a-c">
      <div class="iconfont icon-member-left" @click="onBack"></div>
    </div>
    <div class="commodity-content">
      <div class="commercial">
        <div class="title">{{ storeDetail.store_name }}</div>
        <div class="flex-j-sb classify-mb">
          <div class="flex fine-list">
            <div class="flex-a-c fine-tag">
              <span>{{ storeDetail.first_category }}</span
              ><span class="iconfont icon-advertise-next"></span>
            </div>
            <div class="flex-a-c fine-tag">
              <span>{{ storeDetail.second_category }}</span
              ><span class="iconfont icon-advertise-next"></span>
            </div>
            <div class="flex-a-c fine-tag" v-if="storeDetail.third_category">
              <span>{{ storeDetail.third_category }}</span
              ><span class="iconfont icon-advertise-next"></span>
            </div>
            <div class="flex-a-c fine-tag" v-if="storeDetail.average_price !== '0.00'">
              <span>人均¥{{ storeDetail.average_price }}</span
              ><span class="iconfont icon-advertise-next"></span>
            </div>
          </div>
          <div class="flex-max">
            <div class="commercial-make flex-j-c flex-a-c" @click="onConsult">预约咨询</div>
          </div>
        </div>
        <div class="commercial-information flex-j-sb">
          <div class="flex commercial-time ">
            <div class="time">营业时间：{{ workTime }} {{ storeDetail.work_start_time_str }}-{{ storeDetail.work_end_time_str }}</div>
            <div class="pl">{{ addressDetail }}</div>
            <div class="distance">距你{{ storeDetail.distance | caitalize }}</div>
          </div>
          <div class="commercial-right">
            <div class="flex-a-c commercial-info" @click="onCommercialTo">
              <span>商户信息</span>
              <span class="iconfont icon-advertise-next"></span>
            </div>
            <div class="commercial-location flex">
              <div class="map flex" @click="navigation(storeDetail.latitude, storeDetail.longitude)">
                <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/map.png" />
                <span>地图</span>
              </div>
              <div class="phone flex" @click="phone">
                <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/phone.png" />
                <span>电话</span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="mb20"></div>
      <div class="commercial-content">
        <div class="merchandise-list">
          <div class="groups-title">限时团购</div>
          <div class="merchandise-box" v-if="storeGoodsList.length > 0">
            <block v-for="(item, index) in storeGoodsList" :key="index">
              <div class="merchandise-item flex" @click="goodsDetail(item.id)">
                <div class="img">
                  <div class="merchandise-tag" v-if="item.is_hot">最近热销</div>
                  <img :src="item.thumb" />
                </div>
                <div class="wrap">
                  <div class="merchandise-title ">
                    <span class="official-tag" v-if="item.has_one_store_goods && item.has_one_store_goods.is_self">官方</span>
                    <span class="store-label orange" v-if="item.has_one_store_goods && item.has_one_store_goods.is_free">霸王餐</span>
                    <span class="store-label blue" v-if="item.has_one_store_goods && item.has_one_store_goods.is_new">新品</span>
                    <span class="official-title">{{ item.title }}</span>
                  </div>
                  <div class="small-label flex-a-c">
                    <div class="shop-pay flex-a-c flex-j-c">到店付</div>
                    <div class="original">
                      <span class="sign">￥</span>
                      <span class="price">{{ item.has_one_store_goods && item.has_one_store_goods.offline_price }}</span>
                    </div>
                    <span class="discount"
                      >¥<span class="number">{{ item.has_one_store_goods && item.has_one_store_goods.offline_cost_price }}</span></span
                    >
                    <div class="discount-at flex-j-c">{{ item.has_one_store_goods && item.has_one_store_goods.offline_percent }}折</div>
                  </div>

                  <div class="purchase flex-a-c">
                    <div>
                      <div class="price">
                        <span class="sign">￥</span>
                        <span>{{ item.price }}</span>
                      </div>
                      <div class="packet-label" v-if="item.reward_love">
                        <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/packet-label.png" />购买赠送{{ loveName }}{{ item.reward_love }}
                      </div>
                      <div class="packet-label" v-else-if="item.reward_point">
                        <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/packet-label.png" />购买赠送{{ pointName }}{{ item.reward_point }}
                      </div>
                    </div>
                    <div class="flex-a-c purchase-right">
                      <span class="sold-out">已售{{ item.show_sales }}</span>
                      <div class="purchase-btn flex-a-c flex-j-c">抢购</div>
                    </div>
                  </div>
                </div>
              </div>
            </block>
          </div>
          <van-empty description="空空如也" v-else />
          <div class="merchandise-more flex-a-c flex-j-c" @click="goodsMoreData" v-if="storePage < storeLastPage">
            查看更多
            <span class="iconfont icon-member-bottom"></span>
          </div>
        </div>
      </div>
      <div class="mb20"></div>
      <!-- 商品详情 -->
      <div class="goods-details" v-if="storeDetail.store_detail">
        <div class="details-title flex-a-c flex-j-c">
          <div class="left-line left-mr"></div>
          <span>探店详情</span>
          <div class="left-line left-ml"></div>
        </div>
        <div class="details-content" id="details-content" v-html="storeDetail.store_detail"></div>
      </div>
      <div class="mb140"></div>
    </div>
    <div class="shop-footer flex-a-c" :style="iPnoneBottomBol ? 'padding-bottom: 34px;' : ''">
      <div class="shop-left flex-a-c">
        <div class="shop-index " @click="tapIndex">
          <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/index.png" />
          <div>首页</div>
        </div>
        <div class="shop-service" @click="clickChat">
          <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/kefu.png" />
          <div>客服</div>
        </div>
      </div>
      <div class="shop-right flex-a-c">
        <div class="collect-btn flex-a-c flex-j-c" @click="onCollect">
          <span class="iconfont icon-bc_like like-succees" v-if="collectChecked"></span>
          <span class="iconfont icon-bc_like" v-else></span>
          <span>想去</span>
        </div>
        <div class="poster flex-a-c flex-j-c" @click="onPosterClick">查看海报</div>
      </div>
    </div>

    <van-popup
      v-model="posterShow"
      closeable
      close-on-click-overlay="true"
      @close="onClose"
      custom-style=""
      style="background-color: transparent; background-image: url('');"
      class="posterPopup_style"
      position="center"
    >
      <div class="code_box">
        <img :src="posterImg" mode="widthFix" id="picurl" />
        <img v-if="!posterImg" src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/img_default.png" mode="widthFix" />
      </div>
    </van-popup>

    <div class="poster-down" @click="onClose" v-if="consultShow" :style="posterShow ? 'bottom:1.5625rem' : 'bottom:8.75rem'">
      <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/poster-down.png" />
    </div>
    <van-popup v-model="consultShow" @close="onConsultClose" round>
      <div class="consult-main  flex-a-c">
        <img :src="storeDetail.customer_code_url" class="consultCode-img" v-if="storeDetail.customer_code_url" />
        <div @click="programNav(storeDetail.customer_mini_url)">{{ storeDetail.customer_text }}</div>
      </div>
    </van-popup>
    <!-- <div class="consult-img" v-if="consultShow">
      <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/consult.png" />
    </div> -->

    <yz-service v-model="serviceShow" :url="cservice" :mobile="serviceMobile" :qr="serviceQRcode"></yz-service>
  </div>
</template>
<script>
import commodity_controller from "./commodity_controller.js";
export default commodity_controller;
</script>
<style scoped>
@media only screen and (max-width: 1920px) and (min-width: 960px) {
  .commodity-page .consult-img {
    top: 13.125rem;
  }
}

img {
  width: 100%;
  height: 100%;
}

#appMain.pcStyle .van-popup {
  left: 50%;

  /* width: 245px !important; */

  /* 隐藏滚动条 */
  scrollbar-width: none; /* firefox */
  -ms-overflow-style: none; /* IE 10+ */
}

#appMain.pcStyle .van-popup::-webkit-scrollbar {
  display: none; /* Chrome Safari */
}

.commodity-page ::v-deep .van-popup__close-icon--top-right {
  top: 26px;
  right: 13px;
}

.commodity-page ::v-deep #details-content img {
  max-width: 100% !important;
  height: auto !important;
  display: block;
  border: 0 !important;
}
</style>
<style lang="scss" scoped>
/* packageF/consumption/commodity/commodity.wxss */
.ell {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;

  /* 定义显示的行数 */
  overflow: hidden;
}

.mb20 {
  height: 0.625rem;
  clear: both;
}

.mb140 {
  height: 4.375rem;
  clear: both;
}

.pl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.classify-mb {
  margin-bottom: 35px;
}

.flex-max {
  display: flex;
  flex: 5;
  justify-content: flex-end;
}

.border-b {
  border-bottom: 0.0625rem solid #f5f5f5;
}

.blue {
  background-color: #2aa2ff;
  margin-right: 0.2813rem;
}

.yellow {
  background-color: #ffb536;
  margin-right: 0.2813rem;
}

.orange {
  background-color: #ff3a00;
  margin-right: 0.3438rem;
}

.commodity-page {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-attachment: fixed;
  background-repeat: no-repeat;
  position: relative;

  .banner-bg {
    width: 100%;
    position: absolute;
    z-index: -2;
    left: 0;

    img {
      width: 23.4375rem;
    }
  }

  .commodity-head {
    height: 6.3125rem;
    margin: 0 1.0313rem 0 0.625rem;
    justify-content: flex-end;
    position: relative;
  }

  .icon-member-left {
    font-size: 1.125rem;
    color: #fff;
    position: absolute;
    left: 0.7188rem;
    top: 2.875rem;
  }

  .share {
    margin: 0 1.75rem 0 0;

    .icon-zb_share {
      color: #fff;
      font-size: 1.375rem;
    }
  }

  .more .icon-all_more {
    color: #fff;
    font-size: 1.125rem;
  }

  .commodity-content {
    margin: 0 0.625rem;

    .commercial {
      background-color: #fff;
      border-radius: 0.3125rem;
      padding: 0.9375rem 0.625rem 0.8438rem 0.625rem;

      .title {
        font-size: 1.1719rem;
        color: #222;
        margin: 0 0 0.5313rem 0;
        text-align: left;
      }

      .commercial-make {
        width: 5.1875rem;
        height: 2.125rem;
        line-height: 2.125rem;
        text-align: center;
        background-image: linear-gradient(-85deg, #ff3d04 0%, #ff6a3f 100%);
        font-size: 0.8125rem;
        color: #fff;
        border-radius: 0.3125rem;
      }

      .fine-list {
        flex-wrap: wrap;
        flex: 5;

        .fine-tag {
          font-size: 0.6509rem;
          color: #222;
          padding: 0.0625rem 0.25rem 0.0625rem 0.25rem;
          background-color: #f3f3f5;
          margin: 0 0.2188rem 0.25rem 0;

          .icon-advertise-next {
            font-size: 0.625rem;
          }
        }
      }

      .commercial-time {
        width: 70%;
        flex-direction: column;
        margin-right: 1.5625rem;

        .time {
          margin: 0 0 0.7813rem 0;
          text-align: left;
        }

        .pl {
          margin-bottom: 0.5938rem;
          text-align: left;
        }

        .distance {
          font-size: 0.7163rem;
          color: #979797;
          text-align: left;
        }
      }

      .commercial-right {
        font-size: 0.7813rem;
        color: #979797;

        .commercial-info {
          cursor: pointer;
        }

        .commercial-location {
          margin-top: 0.7813rem;

          .map {
            margin: 0 1.2188rem 0 0;
          }

          .map span,
          .phone span {
            font-size: 0.6509rem;
            color: #979797;
          }

          .map img,
          .phone img {
            width: 1.5313rem;
            height: 1.5313rem;
            margin-bottom: 0.25rem;
          }

          .map,
          .phone {
            flex-direction: column;
          }
        }
      }
    }

    .commercial-content {
      background-color: #fff;
      border-radius: 0.3125rem;

      .merchandise-list {
        margin-top: 0.3125rem;

        .groups-title {
          padding: 0.7188rem 0.6563rem 0.9375rem 0.75rem;
          font-size: 0.875rem;
          font-weight: bold;
        }

        .merchandise-item {
          padding: 0.4063rem 0.6563rem 0.9375rem 0.75rem;

          .img {
            width: 5.9375rem;
            height: 5.9375rem;
            position: relative;
            margin-right: 0.6563rem;

            image {
              width: 5.9375rem;
              height: 5.9375rem;
            }
          }

          .wrap {
            display: flex;
            flex-direction: column;
            flex: 5;
          }

          .merchandise-tag {
            font-size: 0.625rem;
            color: #fff;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 99;
            background: linear-gradient(90deg, #ff6a3f 0%, #ff3b01 100%);
            padding: 0 0.2188rem;
            border-radius: 0.3125rem 0 0.3125rem 0;
          }

          .merchandise-title {
            margin-bottom: 0.5rem;
            display: inline-block;
            height: 100%;
            font-size: 0;
            text-align: left;

            .official-title {
              font-size: 0.875rem;
              line-height: 20px;
              color: #222;
              vertical-align: middle;
            }

            .store-label {
              font-size: 0.625rem;
              color: #fff;
              padding: 2px 4px;
              border-radius: 0.2188rem;
              vertical-align: middle;
            }

            .official-tag {
              // width: 1.875rem;
              // height: 1rem;
              // line-height: 0.9375rem;
              // padding: 0rem 0.25rem 0.0938rem 0.25rem;
              padding: 2px 4px;
              text-align: center;
              font-size: 0.625rem;
              color: #825e00;
              background-color: #ffcc54;
              border-radius: 0.2188rem;
              margin: 0 0.1875rem 0 0;
              vertical-align: middle;
            }
          }

          .shop-pay {
            // width: 2.125rem;
            // height: 0.8438rem;
            // line-height: 0.8438rem;
            padding: 2px 3px;
            border-radius: 0.1563rem;
            text-align: center;
            background-color: #ff4000;
            font-size: 0.625rem;
            color: #fff;
            margin-right: 0.25rem;
          }

          .original {
            color: #ff3a00;
            margin-right: 0.3125rem;

            .sign {
              font-size: 0.6875rem;
            }

            .price {
              font-size: 1rem;
            }
          }

          .discount {
            font-size: 0.6281rem;
            color: #b5b5b5;

            .number {
              text-decoration: line-through;
            }
          }

          .discount-at {
            font-size: 0.625rem;
            color: #ff3a00;
            padding: 0.0938rem 0.1875rem 0.0938rem 0.25rem;
            border-radius: 0.1875rem;
            border: 0.0625rem solid #ff3a00;
            margin-left: 0.25rem;
          }

          .purchase {
            justify-content: flex-end;

            .purchase-btn {
              width: 3.625rem;
              height: 2rem;
              line-height: 2rem;
              text-align: center;
              background-image: linear-gradient(-85deg, #ff3d04 0%, #ff6a3f 100%);
              font-size: 0.875rem;
              color: #fff;
              border-radius: 0.3125rem;
              margin-top: 0.2188rem;
            }

            .purchase-right {
              flex-direction: column;
              margin-left: 0.4063rem;
            }

            .sold-out {
              font-size: 0.625rem;
              color: #b5b5b5;
            }

            .price {
              color: #ff3a00;
              font-size: 1rem;
              text-align: right;

              .sign {
                font-size: 0.6281rem;
              }
            }

            .packet-label {
              padding: 0.125rem 0.3125rem;
              text-align: center;
              background-color: #ffe2d9;
              font-size: 0.625rem;
              color: #ff3a00;
              border-radius: 0.1563rem;

              img {
                width: 0.3125rem;
                height: 0.5rem;
                margin: 0 0.125rem 0 0;
              }
            }
          }
        }
      }

      .merchandise-more {
        padding-bottom: 0.625rem;
      }
    }

    .goods-details {
      background-color: #fff;
      padding: 1.25rem 0.5625rem 0 0.5625rem;
      border-radius: 10px;

      .details-title {
        font-size: 1.0416rem;
        color: #222;
        text-align: center;
        margin-bottom: 0.7813rem;

        .left-line {
          width: 6rem;
          height: 0.0625rem;
          background-color: #dfdfdf;
        }

        .left-mr {
          margin-right: 0.8125rem;
          margin-left: 0.8125rem;
        }
      }

      .details-content {
        img {
          max-width: 100%;
        }
      }
    }
  }

  /* 底部菜单 */
  .shop-footer {
    // width: 100%;
    height: 3.75rem;
    background-color: #fff;
    position: fixed;
    bottom: 0;
    z-index: 99;

    .shop-left {
      margin: 0 1.375rem 0 1.0625rem;

      .shop-service {
        font-size: 0.75rem;
        position: relative;
      }

      .service {
        position: absolute;
        width: 1rem;
        height: 2.8125rem;
        background-color: transparent;
        border: none;
        z-index: 5;

        ::after {
          border: none;
        }
      }

      .shop-index {
        font-size: 0.75rem;
        color: #222;
        margin-right: 1.4063rem;

        .icon-dianpu {
          font-size: 1.0938rem;
          color: #222;
        }
      }

      .shop-service {
        font-size: 0.75rem;
      }

      .shop-service img,
      .shop-index img {
        width: 1.3438rem;
        height: 1.3438rem;
      }
    }

    .shop-right {
      .collect-btn {
        width: 8.1563rem;
        height: 2.5625rem;
        border-radius: 1.25rem 0 0 1.25rem;
        background-color: #ff744b;

        span {
          font-size: 1rem;
          color: #fff;
        }

        .like-succees {
          color: #ffba48;
        }

        .iconfont {
          margin-right: 0.1563rem;
        }
      }
    }

    .poster {
      width: 8.1563rem;
      height: 2.5625rem;
      font-size: 1rem;
      color: #fff;
      background-color: #ff3a00;
      border-radius: 0 1.25rem 1.25rem 0;
    }
  }
}

.merchandise-box {
  overflow: hidden;
}

.poster-main {
  width: 17.5rem;
  height: 23.4375rem;
  background: #fff;
  border-radius: 0.3125rem;

  image {
    width: 17.5rem;
    height: 23.4375rem;
    background: #fff;
    border-radius: 0.3125rem;
  }
}

.poster-down {
  width: 3.5625rem;
  height: 3.5625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  left: 50%;
  bottom: 1.5625rem;
  transform: translateX(-50%);
  z-index: 2500;

  img {
    width: 1.7813rem;
    height: 1.7813rem;
  }
}

.consult-main {
  // top: 58px;
  width: 15.3125rem;
  // height: 18rem;
  flex-direction: column;
  padding: 0.625rem;
  margin: 0 auto;
  position: relative;

  div {
    width: 15.3125rem;
    padding: 0.625rem;
    box-sizing: border-box;
    word-wrap: break-word;
    // text-align: left;
  }

  .consultCode-img {
    // margin-bottom: 10px;
    width: 7.625rem;
    height: 7.625rem;
    margin: 0 0 0.625rem 0;
    // margin-top: 20px;
  }
}

.consult-img {
  position: absolute;
  top: 5rem;
  left: 3.125rem;
  z-index: 2500;

  img {
    width: 16.125rem;
    height: 13.0938rem;
  }
}

/* 客服 */

/* kefu */
.icon-close11 {
  font-size: 36rpx;
}

.pop-content {
  background-color: #fff;
  border-radius: 1.1875rem;
  text-align: center;
  background: #fff;
  padding: 1.0938rem 0;
  position: relative;
  justify-content: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 20.3125rem;

  .pop-top {
    display: flex;
    justify-content: space-between;
    width: 100%;

    .left {
      flex: 1;
      display: flex;
      justify-content: center;
      position: relative;
      margin-bottom: 0.75rem;

      .wrap {
        display: flex;
        flex-direction: column;
        align-items: center;

        .image {
          width: 2.625rem;
          height: 2.625rem;
          margin: 0 auto;
          margin-bottom: 0.5rem;

          image {
            width: 100%;
            height: 100%;
          }
        }
      }
    }

    .right {
      flex: 1;
      display: flex;
      justify-content: center;
      margin-bottom: 0.75rem;

      .wrap {
        display: flex;
        flex-direction: column;
        align-items: center;

        .image {
          width: 2.625rem;
          height: 2.625rem;
          margin: 0 auto;
          margin-bottom: 0.5rem;

          image {
            width: 100%;
            height: 100%;
          }
        }

        icon {
          width: 2.625rem;
          height: 2.625rem;
          margin: 0 auto;
          margin-bottom: 0.5rem;
          border-radius: 50%;
          overflow: hidden;
          font-size: 1.5625rem;
          background-color: #02c777;
          color: #fff;
        }

        .color2 {
          background: #ff9329;
        }

        .color3 {
          background: #2aa7fb;
        }
      }
    }
  }

  .line {
    width: 2rpx;
    height: 1.5938rem;
    background-color: #999;
  }
}

.posterPopup_style {
  /* 海报 */
  .code_box {
    width: 18.625rem;
    // height: 30.3125rem;
    display: block;
    margin: 0 auto 1.875rem;
    border-radius: 0.375rem;

    img {
      margin-top: 1.25rem;
      width: 100%;
      border-radius: 0.375rem;
    }
  }

  .icon_btn {
    width: 100%;
    position: relative;

    /* height: 3.75rem; */
    background: #fff;
    text-align: center;
    display: flex;
    justify-content: space-around;

    .box {
      width: 50%;
      display: flex;
      align-items: center;
      flex-direction: column;
      justify-content: center;
      text-align: center;
      padding: 0.625rem 0;
      position: relative;
    }

    img {
      width: 2.5rem;
      height: 2.5rem;
      margin-bottom: 0.25rem;
    }
  }

  .icon_close {
    width: 100%;
    height: 2.8125rem;
    line-height: 2.8125rem;
    text-align: center;
    background: #efefef;
    color: #333;
    font-size: 1rem;
  }
}
</style>
